package _05_Switch;

public class Switch_01 {

	public static void main(String[] args) {
		char a='A';
		switch(a) {
		case 'A' :
			System.out.println("优秀");
			break;
		case 'B' :
			System.out.println("良好");
			break;
		case 'C' :
			System.out.println("及格");
			break;
		default:
			System.out.println("差");
			break;
		}
		//优秀
		//和下面的等价
		if(a=='A') {
			System.out.println("优秀");
		}else if(a=='B') {
			System.out.println("良好");
		}else if(a=='C') {
			System.out.println("及格");
		}else {
			System.out.println("差");
		}
		//优秀
		//注意break一定要有,不然会有case穿透
		int i=10;
		switch(i) {
		case 1:
			i+=1;
		case 2:
			i+=2;
		case 10:
			i+=10;
		case 11:
			i+=11;
		case 12:
			i+=12;
			break;
		default :
			i+=0;
		}
		//i=10+10+11+12=43
		System.out.println(i);
		//case 合并
		char c='A';
		//相当于||位或,如果是ABC就执行相同的操作
		switch(c){
		case 'A':
		case 'B':
		case 'C':
			System.out.println("111");
			break;
		case 'D':
			System.out.println("222");
			break;
		}
		//111
		//jdk1.7以后可以传入字符串
		switch("111") {
		case "111":
			System.out.println("22");
			break;
		}
		//22
	}
}